package com.cskaoyan.wx.controller;

import com.cskaoyan.bean.ShowRegion;
import com.cskaoyan.vo.BaseRespVo;
import com.cskaoyan.wx.service.FootprintService;
import com.cskaoyan.wx.vo.FootprintVO;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author LiaoLong
 * @date 2021-05-12 20:16
 */
@RestController
@RequestMapping("wx/footprint")
public class FootPrintController {

    @Autowired
    private FootprintService footprintService;

    @GetMapping("list")
    public BaseRespVo list(Integer page, Integer size){
        Subject subject = SecurityUtils.getSubject();
        String username = (String) subject.getSession().getAttribute("username");
        FootprintVO footprintVO = footprintService.getFootprintByUsername(page, size, username);
        return BaseRespVo.ok(footprintVO);
    }

    @PostMapping("delete")
    public BaseRespVo delete(@RequestBody Map map){
        Integer id = (Integer) map.get("id");
        footprintService.deleteFootprint(id);
        return BaseRespVo.ok();
    }
}
